package com.kds.smarthome.common;

import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.annotation.JsonCreator;

public enum DateType {
    DAY("day", "日"),
    MONTH("month", "月"),
    YEAR("year", "年");

    private final String code;
    private final String desc;

    DateType(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @JsonValue
    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    @JsonCreator
    public static DateType fromCode(String code) {
        for (DateType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown DateType code: " + code);
    }
} 